<%@ page language="java" import="java.util.*,com.opensymphony.xwork2.util.*,com.base.service.AddressService" 
pageEncoding="UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="json" uri="http://www.atg.com/taglibs/json" %>  

<!doctype html>
<html lang="zh-hans">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="stylesheet" href="lib/bootstrap/css/bootstrap.min.css">

<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/main.css">    
<script src="lib/jquery-2.1.1.min.js"></script>
<script src="lib/bootstrap/js/bootstrap.min.js"></script>
<title>HIFO</title>
<!-- 省市区 -->
<script type="text/javascript">
function tijiao(){
	//$("#opType").val(2);	
	document.form1.submit();
};


function select1() {
$.ajax(
{
    type: "post",
    url: "getProvince",
    //data: { "code": "" },
    success: function (msg) {
    	$("#S1").append("<option value="  + "0>" + "</option>");
        for (var i = 0; i < msg.length; i++) {
            $("#S1").append("<option value='" +msg[i].provinceId+ "'>" + msg[i].province + "</option>");
        }
        select2();
        
    }
})
};

function select2() {
$("#S2").html("");
$.ajax(
{
    type: "post",
    url: "getCity",
    data: {"code":$('#S1').val()},
    success: function (msg) {
    	$("#S2").append("<option value="  + "0>" + "</option>");
        for (var i = 0; i < msg.length; i++) {
            $("#S2").append("<option value=" + msg[i].cityId + ">" + msg[i].city + "</option>");
        }
        select3();
    }
})
};
        
function select3() {
$("#S3").html("");
$.ajax(
{
    type: "post",
    url: "getArea",
    data: { "code":$('#S2').val()},
    success: function (msg) {
    	$("#S3").append("<option value="  + "0>" + "</option>");
        for (var i = 0; i < msg.length; i++) {
            $("#S3").append("<option value=" + msg[i].areaId + ">" + msg[i].area+ "</option>");
        }
        $("#myadd").val($("#S1 option:selected").text()+"|"+$("#S2 option:selected").text()+"|"+$("#S3 option:selected").text());
        $("#myaddcode").val($("#S1").val()+"|"+$("#S2").val()+"|"+$("#S3").val());
    }
})
};

$(function () {
select1();
$('#S1').bind("change", select2);
$('#S2').bind("change", select3);
});


function check_phone1(){ 	//check phone
	 $.ajax({ url:"check",
	 		data:{phoneName:$("#phone1").val(),type:1}, 
	 		type:'post',
	        success: function(obj){
	        	if(obj.resultState<0){	//出现错误
	        		$("#phone1Tip").removeClass().addClass("input-group-addon");
	   			 	$("#phone1Tip").html(obj.tip);
	   			 	$("#phone1Img").attr("src","images/no.png");
	   			 }
	   			else{
	   				$("#phone1Tip").removeClass();
	   				$("#phone1Img").attr("src","images/yes.png");	
	   				$("#phone1Tip").html("");
	   			} 
	}});   
}


function check_phone2(){ 	//check phone
	 $.ajax({ url:"check",
	 		data:{phoneName:$("#phone2").val(),type:1}, 
	 		type:'post',
	        success: function(obj){
	        	if(obj.resultState<0){	//出现错误
	        		$("#phone2Tip").removeClass().addClass("input-group-addon");
	   			 	$("#phone2Tip").html(obj.tip);
	   			 	$("#phone2Img").attr("src","images/no.png");
	   			 }
	   			else{
	   				$("#phone2Tip").removeClass();
	   				$("#phone2Img").attr("src","images/yes.png");	
	   				$("#phone2Tip").html("");
	   			} 
	}});   
}


function check_phone3(){ 	//check phone
	 $.ajax({ url:"check",
	 		data:{phoneName:$("#phone3").val(),type:1}, 
	 		type:'post',
	        success: function(obj){
	        	if(obj.resultState<0){	//出现错误
	        		$("#phone3Tip").removeClass().addClass("input-group-addon");
	   			 	$("#phone3Tip").html(obj.tip);
	   			 	$("#phone3Img").attr("src","images/no.png");
	   			 }
	   			else{
	   				$("#phone3Tip").removeClass();
	   				$("#phone3Img").attr("src","images/yes.png");	
	   				$("#phone3Tip").html("");
	   			} 
	}});   
}

function check_name(){   //check name
	 $.ajax({ url:"check",
	 		data:{phoneName:$("#name").val(),type:2}, 
	 		type:'post',
	        success: function(obj){
	        	if(obj.resultState<0){	//出现错误
	   			 	//alert(obj.tip);
	        		$("#nameTip").removeClass().addClass("input-group-addon");
	   			 	$("#nameTip").html(obj.tip);
	   			 	$("#nameImg").attr("src","images/no.png");
	   			 }
	   			else{
	   				$("#nameTip").removeClass();
	   				$("#nameImg").attr("src","images/yes.png"); 
	   				$("#nameTip").html("");
	   			}				 
	}});   
} 

// 作废电话
$(function () {
$("#phone1Img").bind("click", function(){
$("#phone1Id").val(-$("#phone1Id").val());
if($("#phone1Id").val()<0)		//waste phone
  $("#phone1").css("color","#ddd");
else
  $("#phone1").css("color","#000");
});

$("#phone2Img").bind("click", function(){
$("#phone2Id").val(-$("#phone2Id").val());
if($("#phone2Id").val()<0)		//waste phone
  $("#phone2").css("color","#ddd");
else
  $("#phone2").css("color","#000");
});

$("#phone3Img").bind("click", function(){
$("#phone3Id").val(-$("#phone3Id").val());
if($("#phone3Id").val()<0)		//waste phone
  $("#phone3").css("color","#ddd");
else
  $("#phone3").css("color","#000");
});

});
</script>
</head>
<body>
<%@ include file="_daohang.jsp" %>	
<form name="form1" action="kh_edit_do" method ="post">

<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingOne">
<h5 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
基本信息
</a>
</h5>
</div>
<div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
<div class="panel-body khdetail">
           
<!-- #################基本信息 START ###################  -->
<div class="form-group">  

<!-- 隐藏数据域 -->
<div class="input-group hide">
<input type="text" class="form-control" id="opType" name="opType" value="<s:property value="opType"/>">
<input type="text" class="form-control" id="cid" name="cid" value="<s:property value="clientDetail.clientBase.cid"/>">
<input type="text" class="form-control" id="phone1Id" name="phone1Id" readonly="readonly" value="<s:property value="clientDetail.clientPhones[0].id"/>">
<input type="text" class="form-control" id="phone2Id"  name="phone2Id" readonly="readonly" value="<s:property value="clientDetail.clientPhones[1].id"/>">
<input type="text" class="form-control" id="phone3Id"  name="phone3Id" readonly="readonly" value="<s:property value="clientDetail.clientPhones[2].id"/>">
</div>

<div class="input-group">
<div class="input-group-addon"><img class="home" src="images/name.png"></div>
<input type="text" class="form-control" id="name" name="name" placeholder="姓名" value="<s:property value="clientDetail.clientBase.name"/>"  onChange="check_name()">
<span class="" id="nameTip"></span>
<div class="input-group-addon"><img class="home" id="nameImg" src="images/zanwei.png"></div>
</div>

<s:if test="phoneNum>0">
<div class="input-group">
<div class="input-group-addon"><img class="home" src="images/phone.png"></div>
<!-- <div class="input-group-addon"><img class="home" src="images/add.png"></div> -->
<input type="text" class="form-control" id="phone1" name="phone1" value="<s:property value="clientDetail.clientPhones[0].phone"/>" readonly="readonly" onChange="check_phone1()">
<span class="" id="phone1Tip"></span>
<div class="input-group-addon" id="phone1Img"><img class="home" src="images/trash.png"></div>
</div>
</s:if>

<s:else>
<div class="input-group">
<div class="input-group-addon"><img class="home" src="images/phone.png"></div>
<!-- <div class="input-group-addon"><img class="home" src="images/add.png"></div> -->
<input type="text" class="form-control" id="phone1" name="phone1" value="" onChange="check_phone1()">
<span class="" id="phone1Tip"></span>
<div class="input-group-addon" id="phone1Img"><img class="home" src="images/zanwei.png"></div>
</div>
</s:else>

<s:if test="phoneNum>1">
<div class="input-group">
<div class="input-group-addon"><img class="home" src="images/phone.png"></div>
<!-- <div class="input-group-addon"><img class="home" src="images/add.png"></div> -->
<input type="text" class="form-control" id="phone2" name="phone2" value="<s:property value="clientDetail.clientPhones[1].phone"/>" readonly="readonly" onChange="check_phone2()">
<span class="" id="phone2Tip"></span>
<div class="input-group-addon" id="phone2Img"><img class="home" src="images/trash.png"></div>
</div>
</s:if>

<s:else>
<div class="input-group">
<div class="input-group-addon"><img class="home" src="images/phone.png"></div>
<!-- <div class="input-group-addon"><img class="home" src="images/add.png"></div> -->
<input type="text" class="form-control" id="phone2" name="phone2" value="" onChange="check_phone2()">
<span class="" id="phone2Tip"></span>
<div class="input-group-addon" id="phone2Img"><img class="home" src="images/zanwei.png"></div>
</div>
</s:else>

<s:if test="phoneNum>2">
<div class="input-group">
<div class="input-group-addon"><img class="home" src="images/phone.png"></div>
<!-- <div class="input-group-addon"><img class="home" src="images/add.png"></div> -->
<input type="text" class="form-control" id="phone3" name="phone3" value="<s:property value="clientDetail.clientPhones[2].phone"/>" readonly="readonly" onChange="check_phone3()">
<span class="" id="phone3Tip"></span>
<div class="input-group-addon" id="phone3Img"><img class="home" src="images/trash.png"></div>
</div>
</s:if>

<s:else>
<div class="input-group">
<div class="input-group-addon"><img class="home" src="images/phone.png"></div>
<!-- <div class="input-group-addon"><img class="home" src="images/add.png"></div> -->
<input type="text" class="form-control" id="phone3" name="phone3" value="" onChange="check_phone3()">
<span class="" id="phone3Tip"></span>
<div class="input-group-addon" id="phone3Img"><img class="home" src="images/zanwei.png"></div>
</div>
</s:else>

<!--  
<s:if test="phoneNum>1">
<div class="input-group">
<div class="input-group-addon"><img class="home" src="images/phone.png"></div>
<input type="text" class="form-control" id="phone2" name="phone2" value="<s:property value="clientDetail.clientPhones[1].phone"/>"  readonly="readonly" onChange="check_phone2()">
<div class="input-group-addon"><span id="phone2Tip"></span><img class="home" id="phone2Img" src="images/zanwei.png"></div>
</div>
</s:if>

<s:else>
<div class="input-group hide">
<div class="input-group-addon"><img class="home" src="images/phone.png"></div>
<input type="text" class="form-control" id="phone2" name="phone2" value="" onChange="check_phone2()">
<div class="input-group-addon"><span id="phone2Tip"></span><img class="home" id="phone2Img" src="images/zanwei.png"></div>
</div>
</s:else>


<s:if test="phoneNum>2">
<div class="input-group">
<div class="input-group-addon"><img class="home" src="images/phone.png"></div>
<input type="text" class="form-control" id="phone3" name="phone3" value="<s:property value="clientDetail.clientPhones[2].phone"/>"  readonly="readonly" onChange="check_phone3()">
<div class="input-group-addon"><span id="phone3Tip"></span><img class="home" id="phone3Img" src="images/zanwei.png"></div>
</div>
</s:if>

<s:else>
<div class="input-group hide">
<div class="input-group-addon"><img class="home" src="images/phone.png"></div>
<input type="text" class="form-control" id="phone3" name="phone3" value="" onChange="check_phone3()">
<div class="input-group-addon"><span id="phone3Tip"></span><img class="home" id="phone3Img" src="images/zanwei.png"></div>
</div>
</s:else>
-->





<!-- 地址显示  -->
<div class="input-group">
<div class="input-group-addon"><img class="home" src="images/zanwei.png"></div>
<input type="text" class="form-control" placeholder="地址名称|分隔" readonly="readonly" 
value="<s:property value="clientDetail.clientBase.province"/>|<s:property value="clientDetail.clientBase.city"/>|<s:property value="clientDetail.clientBase.area"/>" >	
</div>    
       
<div class="input-group">
<div class="input-group-addon">省&nbsp;</div>
<select class="form-control" id="S1" name="provinceId">
	
</select>
<!--<div class="input-group-addon"><img class="home" src="images/zanwei.png"></div>-->
</div>
    
<div class="input-group">
<div class="input-group-addon">市&nbsp;</div>
<select class="form-control" id="S2" name="cityId">

</select>
</div>
    
<div class="input-group">
<div class="input-group-addon">区&nbsp;</div>
<select class="form-control" id="S3" name="areaId">

</select>
</div>
    
    
<div class="input-group">
<div class="input-group-addon"><img class="home" src="images/memo.png"></div>
<textarea class="form-control" rows="3" cols="10" name="memo"><s:property value="clientDetail.clientExtend.memo"/></textarea>
</div>
 

<div class="input-group">
<span><s:property value="tip"/></span>
</div>    
    

  
</div><!--form-group-->
<!-- ################基本信息 END   ###########################       -->           
           
           
           
           
           
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingTwo">
<h4 class="panel-title">
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
扩展信息
</a>
</h4>
</div>
<div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo">
<div class="panel-body khdetail">


<!-- 扩展信息 START   #####################   -->


<!--挖掘机品牌--><div><hr>现有挖机品牌</div>
<div class="form-group">
<s:checkboxlist name="chose1" list="{'卡特','小松','日立','斗山','现代','沃尔沃','神钢','其他'}" value='clientDetail.clientExtend.yywjj.split(",")'/> <br/>
</div>

<!--装载机品牌--><div><hr>现有装机品牌</div>
<div class="form-group">
<s:checkboxlist name="chose2" list="{'柳工','临工','成工','龙工','厦工','山工','其他'}" value='clientDetail.clientExtend.yyzzj.split(",")'/> <br/>
</div>

<!--欲购设备类型--><div><hr>欲购设备类型</div>		
<div class="form-group">
<s:checkboxlist name="chose3" list="{'挖掘机','装载机','其他'}" value='clientDetail.clientExtend.ygsbType.split(",")'/> <br/>
</div>

<!--客户类型--><div><hr>客户分类</div>
<div class="container"><div class="row">

<s:radio name="chose4" list="#{'a':'无&nbsp;','b':'作废&chi;','c':'标记&clubs;','d':'一般&diams;','e':'重要&spades;'}" listKey="key" value="clientDetail.clientExtend.clientType" />

</div></div><!--row--container-->

<!--给赞--><div><hr>经纪人给赞</div>
<div class="container"><div class="row">
<s:radio name="chose5" list="#{'a':'无&nbsp;','b':'赞&hearts;'}" listKey="key" value="clientDetail.clientExtend.isZan" />
</div></div><!--row--container-->


<!--欲购时间--><div><hr>预计购机时间</div>
<div class="container"><div class="row">
<div class="col-xs-12">预计达成销售时间为：<s:property value="clientDetail.clientExtend.sellPlan"/></div>
	<s:select name="chose6"  list="#{0:'无',1:'一月内',2:'二月内',3:'三月内'
		,4:'四月内',5:'五月内',6:'半年内',12:'一年内'}" listKey="key" listValue="value" 
	/>
</div></div><!--row--container-->



<!--  扩展信息 END    ####################  -->

</div></div>

<div class="container navbar-fixed-bottom">
<div class="row">
<!--<div class="col-xs-4"><button type="button" class="btn btn-success">新建</button></div>-->
<div class="col-xs-4"></div>
<!--<div class="col-xs-4"><button type="button" class="btn btn-success">暂存</button></div>-->
<div class="col-xs-8">
    <button type="button" class="btn btn-info center-block" data-toggle="modal" data-target="#myModal">提交</button>
</div>
</div>
</div>

</div></div>   				
				
<!-- 按钮触发模态框 START-->    
<!--
<div class="container navbar-fixed-bottom">
<button type="button" class="btn btn-info center-block" data-toggle="modal" data-target="#myModal">提交</button>
</div>
-->
<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" 
aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<!--<h4 class="modal-title" id="myModalLabel">确认修改</h4>-->
</div>
<!--此处可以加入很多信息-->
<div class="modal-body">
	<!-- <input type="button" class="btn btn-primary" value="确定提交"  onClick="javascript:document.form1.submit()"  /> -->   
    <input type="button" class="btn btn-primary" value="确定提交"  onClick="tijiao()"  />
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>

</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<script>
$(function () { $('#myModal').modal({
	keyboard:false;
})});
</script>
<!--按钮触发模态框 END -->

</form>				

</body>
</html>